<?php
	session_start();
$nPageNumber= 25;
	include("mysql_connect.php");
	
//	var_dump( $_POST['Favorites'] );
	//foreach( $_POST['Favorites'] as $obj ){ echo $obj."<br/>";}
/*
	$strSqlCommand = 'SELECT COUNT(*) 
						FROM ResidentialProperty tbRP
						LEFT JOIN Listing tbLT			ON tbRP.Listing_idListing = tbLT.idListing
						LEFT JOIN StreetAddress tbSA	ON tbLT.StreetAddress_idStreetAddress = tbSA.idStreetAddress
						LEFT JOIN ListingData tbLD		ON tbLT.ListingData_idListingData = tbLD.idListingData
						LEFT JOIN CurrencyFormat tbPR	ON tbLD.Price = tbPR.idCurrencyFormat
						LEFT JOIN Baths tbBT			ON tbBt.idBaths = tbRp.Baths_idBaths
						LEFT JOIN Rooms tbRM			ON tbRm.idRooms = tbRp.Rooms_idRooms
					  	WHERE ( PostalCode = "'. $strKeyWord.'" OR City LIKE "%'.$strKeyWord.'%")';
	if( $isSale == "true" )$strSqlCommand .= ' AND Category_idCategory != 5';
	else $strSqlCommand .= ' AND Category_idCategory = 5';
	$result = mysql_query($strSqlCommand);
	
	//echo $strSqlCommand."<br/>";
	$rowCount = @mysql_fetch_row($result);
*/	
	$_SESSION['StrItem'] = 0;
	$_SESSION['MaxItem'] = count(explode(",",$_POST['Favorites'])) - $nPageNumber;

	$_SESSION['SearchKey'] = 'SELECT idResidentialProperty, idListing, Price, Bedrooms, BathTotal, StreetNumber, StreetDirPrefix, StreetName, UnitNumber, City, StateOrProvince, PostalCode, URL, Latitude, Longitude
								FROM ResidentialProperty tbRP
								LEFT JOIN Listing  tbLT			ON tbRP.Listing_idListing = tbLT.idListing
								LEFT JOIN StreetAddress  tbSA	ON tbLT.StreetAddress_idStreetAddress = tbSA.idStreetAddress
								LEFT JOIN ListingData  tbLD		ON tbLT.ListingData_idListingData = tbLD.idListingData
								LEFT JOIN Baths  tbBT			ON tbBt.idBaths = tbRp.Baths_idBaths
								LEFT JOIN GeographicData tbGEO  ON tbSA.idStreetAddress = tbGEO.idGeographicData
							  	LEFT JOIN PictureData tbPD		ON tbLT.PictureData_idPictureData  = tbPD.idPictureData			
							  	WHERE  idResidentialProperty IN ('.$_POST['Favorites'].')';
//								LEFT JOIN CurrencyFormat  tbPR	ON tbLD.Price = tbPR.idCurrencyFormat
	//LEFT JOIN Rooms  tbRM			ON tbRm.idRooms = tbRp.Rooms_idRooms
	$result = mysql_query($_SESSION['SearchKey'] ." LIMIT ".$_SESSION['StrItem'].", ".$nPageNumber);
	
	$_SESSION["MapAddress"] = 'https://maps.googleapis.com/maps/api/staticmap?center=';
	$nIdx = 0;
	
	include_once("OutputPropertyList.php");
	while($rowDetail = @mysql_fetch_array($result))	
	{// URL, Price,idListing
		PrintProperty( $rowDetail, $nIdx);
		$nIdx++;
/*	
				echo '<a class="ViewDetailBlock" id="'.$rowDetail['idResidentialProperty'].'" href="#page14" style="text-decoration: none; color: #000000;">';
		echo '<div class="ui-grid-a ">';
			echo '<div class="ui-block-a property-image" style="position: relative">';
					echo '<img src="'.$_SESSION['Host'].$_SESSION['ImagePath'].$rowDetail['idListing'].'-1.jpeg"/>';
			echo '</div>';
		
		$strAddress = $rowDetail['StreetNumber']. '+'.$rowDetail['StreetName'] . '+' . $rowDetail['City'];
		if($nIdx == 0)
		{
			$_SESSION["MapAddress"] .= $strAddress . "&zoom=11&size=288x400";
		}
		$nIdx++;
		$_SESSION["MapAddress"] .= "&markers=label:".$nIdx."%7C".$strAddress;		

			echo '<div class="ui-block-b property-description">';
				echo '<div>';
					echo "<p>".$rowDetail['StreetNumber']." ".$rowDetail['StreetName']."</p>";
					echo "<p>".$rowDetail['City'].", ".$rowDetail['PostalCode']."</p>";
					//echo "<p>".$rowType[0]." Bedrooms, ".$rowType[1]." Bathrooms</p>";
					echo "<p>".$rowDetail['TotalRooms']." Bedrooms, ".$rowDetail['BathTotal']." Bathrooms</p>";
					echo "<p>".$rowDetail['Currency']."</p>";
				echo "</div>";
				echo '<div>';
					include_once( "getLatLong.php" );
					$geoLatLon = getLatLong( $rowDetail['StreetNumber']." ".$rowDetail['StreetName']." ".$rowDetail['UnitNumber'].
										" ".$rowDetail['City']." ".$rowDetail['StateOrProvince']." ".$rowDetail['PostalCode'] );
					$lat = $geoLatLon['lat'];
					$long = $geoLatLon['long'];
					
					
//					getWalkScore( $geoLatLon['lat'], $geoLatLon['long'], 
//										$rowDetail['StreetNumber']." ".$rowDetail['StreetName']." ".$rowDetail['UnitNumber'].
//										" ".$rowDetail['City']." ".$rowDetail['StateOrProvince']." ".$rowDetail['PostalCode'] );
					//echo $json;
					
				echo "</div>";
			echo '</div>';
		echo '</div>';//class="ui-grid-a"
				echo '</a>';
*/
	}
	
	$_SESSION["MapAddress"] .= "&sensor=false";
?>